<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class MoneyLogRescource extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        /** @var \App\Models\MoneyLog $log */
        $log = $this;
        return [
            'name' => $log->name,
            'created_at' => $log->created_at->toDateTimeString(),
            'money' => $log->money,
            'user' => $log->user->name,
            'buy_user' => $log->buy_user,
            'buy'=>$log->buy,
            'type' => $log->type,
            'money_no'=>$log->money_no,
            'change_type' => $log->change_type,
            'pay_status' => $log->pay_status,
            'pay_at' => $log->pay_at ? $log->pay_at->toDateTimeString() : ''
        ];
    }
}
